package cn.istartfinancial.controller.flowable;

import org.apache.commons.io.IOUtils;
import org.flowable.common.engine.api.FlowableException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.io.InputStream;

/**
 * @author: Nzp
 * @date: 2018/8/31 9:33
 * @description: 添加汉化文件
 */
@RestController
@RequestMapping("/service")
public class StencilsetRestResource
{

    @RequestMapping(value = "/editor/stencilset",
            method = RequestMethod.GET,
            produces = "application/json;charset=utf-8")
    @ResponseBody
    public String getStencilset()
    {
        InputStream stencilsetStream =
                this.getClass().getClassLoader().getResourceAsStream("stencilset.json");
        try
        {
            return IOUtils.toString(stencilsetStream, "utf-8");
        } catch (Exception e)
        {
            throw new FlowableException("Error while loading stencil set", e);
        }
    }
}